﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="BannerManger.aspx.cs" Inherits="TimKen.Web.Admin.Advertisement.BannerManger" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentLinkAction" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentTitle" runat="server">
<%=GetLangString("BManger")%>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentMain" runat="server">

    <script src="../../Common/Script/jquery-1.7.2/jquery-1.7.2.js" type="text/javascript"></script>

<script type="text/javascript">
        function Upward(va) {
            var s = va.closest('tr').index();
            var sh = $("#ContentMain_grdOrderList tr").eq(s - 1);
            var currnt = $("#ContentMain_grdOrderList tr").eq(s);
            var tt = sh.find("img").eq(1).attr("title");
            var tt1 = currnt.find("img").eq(1).attr("title");
            if (s != 1) {
                $.ajax({
                    //要用post方式   
                    type: "POST",
                    //方法所在页面和方法名   
                    url: "BannerManger.aspx/updateOrder",
                    //data: "{abc:111}", //带参数的,参数名称abc,参数“111”
                    data: '{"id1":"' + tt + '","id2":"' + tt1 + '"}', //没有参数的初始化
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        //返回的数据用data.d获取内容   
                        if (data.d == true) {   
                        var td1 = sh.find("td");
                        var td2 = currnt.find("td");
                        sh.find("td").remove();
                        sh.append(td2);
                        currnt.find("td").remove();
                        currnt.append(td1);
////                        sh.addClass("TrBgColor").siblings("tr").removeClass("TrBgColor");
//                        sh.focus();
                        }
                    },
                    error: function (err) {
                        alert(err);
                    }
                });

            } else {
                alert("当前行已处于最上方，无法继续移动！");
            }
        }
        function Downward(va) {
           // $(this).parents("tr").addClass("TrBgColor").siblings("tr").removeClass("TrBgColor");
            var s = va.closest('tr').index() ;
            var len = $("#ContentMain_grdOrderList tr").length - 1;
            var sh = $("#ContentMain_grdOrderList tr").eq(s + 1);
            var currnt = $("#ContentMain_grdOrderList tr").eq(s);
            var tt = sh.find("img").eq(1).attr("title");
            var tt1 = currnt.find("img").eq(1).attr("title");
            if (s != len) {
                $.ajax({
                    //要用post方式   
                    type: "POST",
                    //方法所在页面和方法名   
                    url: "BannerManger.aspx/updateOrder",
                    data: '{"id1":"' + tt + '","id2":"' + tt1 + '"}', //没有参数的初始化
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(data) {
                        //返回的数据用data.d获取内容   
                        if (data.d == true) {
                            var td1 = sh.find("td");
                            var td2 = currnt.find("td");
                            sh.find("td").remove();
                            sh.append(td2);
                            currnt.find("td").remove();
                            currnt.append(td1);
                        }
                    },
                    error: function(err) {

                    }
                });
            } else {
                alert("当前行已处于最下方，无法继续移动！");
            }
        }
        function ShowNum() {
            alert("您推荐的图片已经有了五张！");
         }
        function zt(i) {
            if (i == 1) {
                alert("状态修改成功！");
            } else {
                alert("状态修改失败！");
            }
         }
        function Al() {
            alert("删除成功！");
        }
        function Als() {
            alert("删除失败！");
        }
    </script>
    <div class="list-div">
        <asp:GridView ID="grdOrderList" runat="server" AutoGenerateColumns="False"
            CssClass="grid" OnSorting="grdOrderList_Sorting" 
            OnRowDataBound="grdOrderList_RowDataBound" 
            onrowcommand="grdOrderList_RowCommand">
            <Columns>
            <asp:TemplateField>
                    <ItemStyle Width="150" />
                    <HeaderStyle HorizontalAlign="Center" />
                    <HeaderTemplate>
                        
                        <%=GetLangString("xz")%>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="ck_Tb" runat="server" Checked='<%# Eval("isShow").ToString()=="0"?false:true%>' ToolTip='<%#Eval("id")%>'  />
                        &nbsp;
                        <asp:ImageButton ID="btnUpdateOrder" runat="server" ToolTip='<%#GetLangString("Update")%>'
                            CommandName="UpdateOrder" CommandArgument='<%#Eval("id")%>' ImageUrl="~/Admin/images/icon_OK.gif" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle Width="150" />
                    <HeaderStyle HorizontalAlign="Center" />
                    <HeaderTemplate>
                        
                        <%=GetLangString("num") %>
                    </HeaderTemplate>
                    <ItemTemplate>
                       <%#Eval("rownum")%>
                    </ItemTemplate>
                </asp:TemplateField>
                
                <asp:BoundField SortExpression="Url" DataField="Url" />
                
               <%-- <asp:BoundField SortExpression="Oby" DataField="Oby"  DataFormatString="{0:d}" />--%>
                  <asp:TemplateField>
                    <ItemStyle Width="150" />
                    <HeaderStyle HorizontalAlign="Center" />
                    <HeaderTemplate>
                        <%=GetLangString("imge")%>
                    </HeaderTemplate>
                    <ItemTemplate>
                     <img src="../../<%#Eval("ImagePath")%>" width="70px" height="30px" style=" border:1px solid #ccc"/>  
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField SortExpression="CreDate" DataField="CreDate"  DataFormatString="{0:d}" />
                <asp:TemplateField>
                    <HeaderTemplate>
                        <%=GetLangString("ody")%>
                    </HeaderTemplate>
                    <ItemTemplate>
                    <img src="../images/arrow_up.png" width="15px" height="15px" onclick="Upward($(this))" title='<%#Eval("id")%>' />
                     <img src="../images/arrow_down.png" width="15px" height="15px"  onclick="Downward($(this))" />
                     
                       <asp:ImageButton ID="Ord_Up" runat="server" OnClientClick="Upward($(this))" ToolTip='<%#Eval("id")%>' Visible="false" />
                         <asp:ImageButton ID="Ord_Down" runat="server" OnClientClick="Downward($(this))" Visible="false"  />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemStyle Width="80" HorizontalAlign="Center" />
                    <HeaderTemplate>
                        <%=GetLangString("Operation")%>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:LinkButton ID="uppdate"  CommandArgument='<%#Eval("id")%>' CommandName="upd" runat="server">修改</asp:LinkButton>
                        <asp:LinkButton ID="delete" runat="server" CommandArgument='<%#Eval("id")%>' CommandName="del" OnClientClick="return confirm('您确定要删除此记录?')" >删除</asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>
               
            </Columns>
            <HeaderStyle HorizontalAlign="Center" />
        </asp:GridView>
        <div class="pager-div">
            <ux:AspNetPager ID="AspNetPager1" runat="server" Width="100%" ShowPageIndexBox="Always" PageSize="20"
                HorizontalAlign="right" EnableTheming="true" AlwaysShow="true" PageIndexBoxType="DropDownList"
                OnPageChanged="AspNetPager1_PageChanged" ImagePath="/images/" NavigationButtonType="Image"
                ButtonImageNameExtension="n" CpiButtonImageNameExtension="r" PagingButtonType="Image">
            </ux:AspNetPager>
        </div>
    </div>
</asp:Content>
